//
//  TraintargetSlider.m
//  CoolTennisBall
//
//  Created by Coollang on 16/7/20.
//  Copyright © 2016年 CoolLang. All rights reserved.
//

#import "TraintargetSlider.h"
#import "ASValuePopUpView.h"

#define angleToArc(angle) (angle *M_PI/180)


@implementation TraintargetSlider

- (CGRect)trackRectForBounds:(CGRect)bounds {
    return CGRectMake(0, 0, self.bounds.size.width, 6);
}


- (instancetype)initWithCoder:(NSCoder *)aDecoder
{
    if (self = [super initWithCoder:aDecoder]) {
        [self showPopUpViewAnimated:NO];
        self.font = [UIFont systemFontOfSize:11 weight:1.5];
        self.popUpViewColor = [UIColor colorWithHex:0xd4d4d4];
        self.textColor = kHasReadColor;
        [self setMaximumTrackTintColor:[UIColor colorWithHex:0xd4d4d4]];
        self.minValue = 0;
    }
    return self;
}
- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        [self showPopUpViewAnimated:NO];
        self.font = [UIFont systemFontOfSize:11 weight:1.5];
        self.popUpViewColor = [UIColor colorWithHex:0xd4d4d4];
        self.textColor = kHasReadColor;
        [self setMaximumTrackTintColor:[UIColor colorWithHex:0xd4d4d4]];
        self.minValue = 0;

    }
    return self;
}


- (void)setSliderValueAndCurrentTarget:(NSInteger)CurrentTarget {
    self.curretTarget = CurrentTarget;
    self.value = ((self.curretTarget - self.minValue)/ (self.sliderSpan * 100)) * UnitSpace((self.maxValue - self.minValue), self.sliderSpan);
}

- (void)setSliderSpan:(CGFloat)span maxValue:(NSInteger)maxValue dataSource:(id<ASValueTrackingSliderDataSource>)dataSource {
    self.maxValue = maxValue;
    self.sliderSpan = span;
    self.dataSource = dataSource;
}

- (void)setSliderSpan:(CGFloat)span maxValue:(NSInteger)maxValue minValue:(NSInteger)minValue dataSource:(id<ASValueTrackingSliderDataSource>)dataSource {
    
    [self setSliderSpan:span maxValue:maxValue dataSource:dataSource];
    self.minValue = minValue;
}

@end

